473,467 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using Toolkit.getDefaultToolkit().getImage() within JSP

I am attempting to upload a picture to a webserver and create a
thumbnail from the picture uploaded. The problem comes in when I
attempt to create an Image object from the File object (which is the
location of the uploaded picture)...I get the following error:

java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at java.awt.Toolkit$2.run(Toolkit.java:712)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:70 3)
at _admin._addpicture__jsp._jspService(/www/mcmanis.scharlemann.com/admin/addpicture.jsp:89)
at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(Fi lterChainPage.java:176)
at com.caucho.server.http.Invocation.service(Invocati on.java:278)
at com.caucho.server.http.ServletServer.serviceTop(Se rvletServer.java:847)
at com.caucho.server.http.HttpRequest.handleRequest(H ttpRequest.java:213)
at com.caucho.server.http.HttpRequest.handleConnectio n(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection. java:140)
at java.lang.Thread.run(Thread.java:536)
Basically here is what happens. I use a multipart/form-data html form
within my html page to upload the picture to the server. I have no
problem doing this. The picture is saved in a temporary location. I
then attempt to create a thumbnail from the picture with the code from
here: http://www.geocities.com/marcoschmid...thumbnail.html

The problem is...whether in a JavaBean...or directly in the JSP
page...the line where I try to create the Image with the Toolkit
throws the NoClassDefFoundError.
Line 87 in addpicture.jsp is:
Image image = Toolkit.getDefaultToolkit().getImage(
file.getCanonicalPath());

where file is the object pointing to the temporary location of the
uploaded picture. If anyone has any idea how to fix/get arround this
problem I would appreciate any help. Thanks
Jul 17 '05 #1
1 10803
On 30 Aug 2003 20:58:00 -0700, gr**@dreamatlantic.com (Greg Scharlemann)
two-finger typed:
I am attempting to upload a picture to a webserver and create a
thumbnail from the picture uploaded. The problem comes in when I
attempt to create an Image object from the File object (which is the
location of the uploaded picture)...I get the following error:

java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at java.awt.Toolkit$2.run(Toolkit.java:712)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:70 3)
at _admin._addpicture__jsp._jspService(/www/mcmanis.scharlemann.com/admin/addpicture.jsp:89)
at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(Fi lterChainPage.java:176)
at com.caucho.server.http.Invocation.service(Invocati on.java:278)
at com.caucho.server.http.ServletServer.serviceTop(Se rvletServer.java:847)
at com.caucho.server.http.HttpRequest.handleRequest(H ttpRequest.java:213)
at com.caucho.server.http.HttpRequest.handleConnectio n(HttpRequest.java:158)
at com.caucho.server.TcpConnection.run(TcpConnection. java:140)
at java.lang.Thread.run(Thread.java:536)
Basically here is what happens. I use a multipart/form-data html form
within my html page to upload the picture to the server. I have no
problem doing this. The picture is saved in a temporary location. I
then attempt to create a thumbnail from the picture with the code from
here: http://www.geocities.com/marcoschmid...thumbnail.html

The problem is...whether in a JavaBean...or directly in the JSP
page...the line where I try to create the Image with the Toolkit
throws the NoClassDefFoundError.
Line 87 in addpicture.jsp is:
Image image = Toolkit.getDefaultToolkit().getImage(
file.getCanonicalPath());

where file is the object pointing to the temporary location of the
uploaded picture. If anyone has any idea how to fix/get arround this
problem I would appreciate any help. Thanks

I think the problem here is, that you cannot use the Image subsystem (or
any AWT peering classes) when you are not running within the shell of an
X-Windows system.
So, you may need to have an initialized X-Windows running on the server for
this to work properly.

You could write your own algorithm so read the file, interpret the data and
create the proper data for an output file - all from the bytes you read.

JPEG but is a lot of algorithmic work, and while GIF is easiest to read, it
has a few peculiarities like animation that can make things harder.

Cheers.

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dado | last post by:
I create the jar with my classes, pictures and some txt files. The application is starting just fine if picture folder is out of the jar. If the folder picture is in the jar I don't see the...
6
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls...
16
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the...
2
by: noleander | last post by:
I'm trying to get Vis C++ std to compile using /O2 optimizing flag. Many people have suggested downloading the MS C++ 2003 Toolkit ... it supposedly has C++ compiler bins that one could use. I...
2
by: Kris | last post by:
Hi All, I'm trying to use the GetImage method in a ASP.NET project that I've created but I keep getting an error stating: The name 'GetImage' does not exist in the class or namespace ... ...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
9
by: JuniorProgrammer | last post by:
Please This is queit a task av been trying to solve. Could anyone please tell me how to read a blob from an SQL using a dataset and stuffing this image into the Image control of a webform. Any...
1
by: Manticure | last post by:
I want to get the R, G and B components as integers (0-255). I use this: Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage bufferedImage =...
3
by: mukeshrasm | last post by:
Hi i have a page "newlaunching.php" page on which image is displayed and when user clicks one of thumbnail its larger image comes to this page(newlaunching.php) from "getimage.php"page using ajax...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.